package com.demoandroid.demo.x5;

import androidx.appcompat.app.AppCompatActivity;
import com.demoandroid.demo.R;
import android.os.Bundle;
import android.view.KeyEvent;


/*
 * @DateTime 2020/6/29 16:51
 * @Author zwb
 * @Des X5内核WebView页面
 * */
public class X5TbsWebViewPage extends AppCompatActivity {
    private X5WebView  mX5WebView ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_x5_tbs_web_view_page);
        mX5WebView = (X5WebView) findViewById(R.id.mX5WebView);
        mX5WebView.loadUrl("https://x5.tencent.com/");
    }
    /*返回上个页面  */
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (mX5WebView != null && mX5WebView.canGoBack()) {
                mX5WebView.goBack();
                return true;
            } else {
                return super.onKeyDown(keyCode, event);
            }
        }
        return super.onKeyDown(keyCode, event);
    }
    @Override
    protected void onDestroy() {
        //释放资源
        if (mX5WebView != null){
            mX5WebView.destroy();
        }
        super.onDestroy();
    }
}